package com.nuoniu.sibanyun.controller;

import com.nuoniu.sibanyun.common.exception.NuoNiuException;
import com.nuoniu.sibanyun.common.lang.StringUtils;
import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.common.text.PinyinUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName SysToolController
 * @Description TODO
 * @Authpr baiqiang
 * @Date 2020/7/24 15:50
 **/
@RestController
@RequestMapping("/sysTool")
@Api(value = "系统工具类", tags = "系统工具类")
public class SysToolController {

    @GetMapping("/getPhonetic")
    @ResponseBody
    @ApiOperation(value = "获取拼音首字母")
    public HttpResult getPhonetic(String keyword){
        if(StringUtils.isBlank(keyword)){
            throw new NuoNiuException("关键字不能为空");
        }
        String result = PinyinUtils.getFirstSpell(keyword);
//        ChineseCharToEnUtil cte = new ChineseCharToEnUtil();
//        String result = cte.getAllFirstLetter(keyword);
        return HttpResult.ok(result);
    }
}
